<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>倒计时跳转到百度</title>
		<!-- 1:写一个页面，倒计时9秒后跳转到baidu，
		同时页面上显示剩余的秒数。 -->
		<style>
			#main{
				width: 300px;
				height: 200px;
				line-height: 200px;
				text-align: center;
				margin: auto auto;
				border: 1px solid black;
				font-size: 20px;
				font-weight: 400;
			}
		</style>
	</head>
	<body>
		<div id="main">
			9
		</div>
		<script>
			var time=8;
			var main=document.getElementById("main");
			var timer=window.setInterval(function(){
				main.innerHTML=time;
				time--;
				if(time<1){
					window.location.href="https://www.baidu.com";
				}
			},1000);
		</script>
	</body>
</html>